package selenium.webedriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.*;
import org.openqa.selenium.interactions.Actions;

public class demo {
	
	public static void main(String args[])//添加MAIN方法，程序的入口，在类hello里面。
	{
		/*System.setProperty("webdriver.firefox.bin", "C:/Program Files (x86)/Mozilla Firefox/firefox.exe");
		WebDriver driver = new FirefoxDriver();
		driver.get("http://www.baidu.com/");
		driver.manage().window().maximize();
		WebElement txtbox = driver.findElement(By.name("wd"));
		txtbox.sendKeys("Glen");
		WebElement btn = driver.findElement(By.id("su"));
		btn.click();
		driver.close();*/
		
		System.setProperty("webdriver.chrome.driver", "C:\\Tool\\chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        driver.get("http://www.baidu.com/");
        driver.manage().window().maximize();
		WebElement txtbox = driver.findElement(By.name("wd"));
		//txtbox.sendKeys("Glen");
		//WebElement btn = driver.findElement(By.id("su"));
		//btn.click();
		//driver.close();
		
		Actions actions = new Actions(driver);
		actions.moveToElement(txtbox);
		actions.click();
		actions.sendKeys("Some Name");
		actions.build().perform();
		WebElement btn = driver.findElement(By.id("su"));
		actions.moveToElement(btn);
		actions.click();
		actions.build().perform();
		//driver.close();
	}
	
	

}
